<template>
    <div id="default-layout">
        <nav-bar></nav-bar>
        <div class="main-content">
            <side-bar class="sidebar"></side-bar>
            <div class="page-content">
                <!-- 你的页面内容插槽 -->
                <router-view></router-view>
            </div>
        </div>
    </div>
</template>

<script>
import NavBar from '@/components/layouts/NavBar.vue';
import SideBar from '@/components/layouts/SideBar.vue';

export default {
    name: 'DefaultLayout',
    components: {
        NavBar,
        SideBar
    }
};
</script>

<style>
/* 重置一些基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#app {
    height: 100%;
}

#default-layout {
    min-height: 100vh;
    background-color: #f0f2f5;
}

.main-content {
    position: relative;
    padding-top: 64px; /* NavBar 的高度 */
    min-height: calc(100vh - 64px);
    display: flex;
}

.sidebar {
    position: fixed;
    top: 64px; /* NavBar 的高度 */
    left: 0;
    bottom: 0;
    width: 200px;
    background-color: #545c64;
    z-index: 1000;
    overflow-y: auto;
}

.page-content {
    margin-left: 200px; /* 与侧边栏宽度相同 */
    flex: 1;
    padding: 20px;
    background-color: #fff;
    min-height: calc(100vh - 64px);
}

/* 响应式布局调整 */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-200px);
        transition: transform 0.3s;
    }

    .page-content {
        margin-left: 0;
    }

    /* 当菜单展开时的样式 */
    .sidebar.expanded {
        transform: translateX(0);
    }
}
</style>